/**
 * 
 */
package com.hu.ta.assignment6.beans;

/**
 * @author cage@g.com
 */
public class Token {

	private final String token;
	private int spamCount;
	private int hamCount;

	public Token(final String token) {
		this(token, 0, 0);
	}

	public Token(final String token, int spam, int ham) {
		this.token = token;
		spamCount = spam;
		hamCount = ham;
	}

	public String getToken() {
		return token;
	}

	public void incNum(EmailClass clas) {
		switch (clas) {
		case HAM:
			hamCount++;
			break;
		case SPAM:
			spamCount++;
			break;
		default:
			break;
		}
	}

	public int getCount(EmailClass clas) {
		switch (clas) {
		case HAM:
			return hamCount;
		case SPAM:
			return spamCount;
		default:
			return 0;
		}
	}

	public double getProbability(EmailClass clas) {
		switch (clas) {
		case HAM:
			return Math.log((double)hamCount / (double)(spamCount + hamCount));
		case SPAM:
			return Math.log((double)spamCount / (double)(spamCount + hamCount));
		default:
			return 0.0;
		}
	}
}
